package com.spring.demo6.eg8;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;

import java.util.Map;

/**
 * @author vhans
 */
public class MainConfig12 {
    @Bean
    @Qualifier("tag1")
    public Service1 service1() {
        return new Service1();
    }

    @Bean
    @Qualifier("tag1")
    public Service2 service2() {
        return new Service2();
    }

    @Bean
    @Qualifier("tag2")
    public Service4 service4() {
        return new Service4();
    }

    // 4.Bean结合@Qualidier,这里限定标签为 tag1 的bean能够注入
    @Bean
    public InjectService injectService(@Qualifier("tag1")Map<String, IService> serviceMap) {
        InjectService injectService = new InjectService();
        injectService.setServiceMap(serviceMap);
        return injectService;
    }
}
